

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=dark>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/my-blog/img/fluid.png">
  <link rel="icon" href="/my-blog/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="木舟">
  <meta name="keywords" content="python Vue Test 测试开发 自动化测试">
  
    <meta name="description" content="简介Javascript，简称js。 语言特性是目前唯一一个能在浏览器中运行的编程语言，js有以下特性：  解释性语言，所以有点就是跨平台，和python一样。 单线程语言，或者说执行它的引擎为单线程 弱类型语言  js内容分类目前，js的核心内容主要分为三大类：  ECMA标准内容，也叫js原生 DOM，操作页面元素 BOM，操作浏览器  后续关于js的部分，记录顺序为：ECMA标准内容–&amp;gt">
<meta property="og:type" content="article">
<meta property="og:title" content="javascript简介">
<meta property="og:url" content="https://walker_kwu.gitee.io/my-blog/2022/09/20/notes/js/jsIntroduction/">
<meta property="og:site_name" content="My Blog">
<meta property="og:description" content="简介Javascript，简称js。 语言特性是目前唯一一个能在浏览器中运行的编程语言，js有以下特性：  解释性语言，所以有点就是跨平台，和python一样。 单线程语言，或者说执行它的引擎为单线程 弱类型语言  js内容分类目前，js的核心内容主要分为三大类：  ECMA标准内容，也叫js原生 DOM，操作页面元素 BOM，操作浏览器  后续关于js的部分，记录顺序为：ECMA标准内容–&amp;gt">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-09-20T05:58:46.000Z">
<meta property="article:modified_time" content="2023-05-23T10:37:53.257Z">
<meta property="article:author" content="木舟">
<meta property="article:tag" content="测试开发">
<meta property="article:tag" content="测试平台">
<meta property="article:tag" content="javascript">
<meta name="twitter:card" content="summary_large_image">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>javascript简介 - My Blog</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/my-blog/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/my-blog/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/my-blog/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"walker_kwu.gitee.io","root":"/my-blog/","version":"1.9.2","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/my-blog/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/my-blog/js/utils.js" ></script>
  <script  src="/my-blog/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.2.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/my-blog/">
      <strong>木舟</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my-blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/my-blog/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="javascript简介"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        木舟
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-09-20 13:58" pubdate>
          2022年9月20日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          6.1k 字
        
      </span>
    

    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">javascript简介</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2023年5月23日 晚上
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h1><p>Javascript，简称js。</p>
<h2 id="语言特性"><a href="#语言特性" class="headerlink" title="语言特性"></a>语言特性</h2><p>是目前唯一一个能在浏览器中运行的编程语言，js有以下特性：</p>
<ul>
<li>解释性语言，所以有点就是跨平台，和python一样。</li>
<li>单线程语言，或者说执行它的引擎为单线程</li>
<li>弱类型语言</li>
</ul>
<h2 id="js内容分类"><a href="#js内容分类" class="headerlink" title="js内容分类"></a>js内容分类</h2><p>目前，js的核心内容主要分为三大类：</p>
<ul>
<li>ECMA标准内容，也叫js原生</li>
<li>DOM，操作页面元素</li>
<li>BOM，操作浏览器</li>
</ul>
<p>后续关于js的部分，记录顺序为：ECMA标准内容–&gt;DOM–&gt;BOM</p>
<h2 id="作用"><a href="#作用" class="headerlink" title="作用"></a>作用</h2><p>js最大的作用就是控制页面行为。</p>
<p>简单来说，就是空间页面元素的加载、交互、动作、动画、数据渲染。</p>
<h2 id="关于单线程"><a href="#关于单线程" class="headerlink" title="关于单线程"></a>关于单线程</h2><p>单线程，顾名思义。</p>
<blockquote>
<p>同一时间内，只有一个线程在工作</p>
</blockquote>
<p>但我们经常会看到一个现象：</p>
<ul>
<li>加载静态资源文件，是批量加载的</li>
<li>一个页面上会出现两个以上的动画。</li>
</ul>
<p>不是说js是单线程执行吗？那为什么会造成了像多线程一样的效果呢？</p>
<p>这个其实和python一样，python也是单线程工作，没有真正意义上的多线程。</p>
<p>在面对多任务时，会存在：<strong>线程任务切换</strong></p>
<p>在js里面，就叫：<strong>轮转时间片</strong>。</p>
<p>它会把不同的任务，拆分成一个个小的任务片段，并且随机存放在一个队列中。按照队列的存放顺序来执行。</p>
<h1 id="如何引用js"><a href="#如何引用js" class="headerlink" title="如何引用js"></a>如何引用js</h1><h2 id="内部javascript"><a href="#内部javascript" class="headerlink" title="内部javascript"></a>内部javascript</h2><p>在script标签中直接编写js代码。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/javascript&quot;</span>&gt;</span><span class="language-javascript"></span><br><span class="language-javascript">    <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">write</span>(<span class="hljs-string">&quot;hello world&quot;</span>)</span><br><span class="language-javascript"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="外部javascript"><a href="#外部javascript" class="headerlink" title="外部javascript"></a>外部javascript</h2><p>在script中，通过src属性来引入外部js文件</p>
<p>test.js</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-variable language_">document</span>.<span class="hljs-title function_">write</span>(<span class="hljs-string">&quot;hello world&quot;</span>)<br></code></pre></td></tr></table></figure>

<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;text/javascript&quot;</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;./test.js&quot;</span> &gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h2 id="行内javascript"><a href="#行内javascript" class="headerlink" title="行内javascript"></a>行内javascript</h2><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;javascript:alert(&#x27;点我吧&#x27;);&quot;</span>&gt;</span>点我吧<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h1 id="基本语法"><a href="#基本语法" class="headerlink" title="基本语法"></a>基本语法</h1><h2 id="注释"><a href="#注释" class="headerlink" title="注释"></a>注释</h2><h3 id="单行注释"><a href="#单行注释" class="headerlink" title="单行注释"></a>单行注释</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 单行注释</span><br></code></pre></td></tr></table></figure>

<h3 id="多行注释"><a href="#多行注释" class="headerlink" title="多行注释"></a>多行注释</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">/*</span><br><span class="hljs-comment">  多行注释</span><br><span class="hljs-comment">  多行注释</span><br><span class="hljs-comment"> */</span><br></code></pre></td></tr></table></figure>

<h2 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h2><h3 id="声明方式"><a href="#声明方式" class="headerlink" title="声明方式"></a>声明方式</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> a1; <span class="hljs-comment">// 先声明变量，供下面的代码使用，全局变量，可重新赋值</span><br>a1 = <span class="hljs-number">1</span>  <span class="hljs-comment">// 变量赋值</span><br><span class="hljs-keyword">var</span> a2 = <span class="hljs-number">1</span>;  <span class="hljs-comment">// 声明的同时赋值</span><br><br><span class="hljs-keyword">let</span> b1; <span class="hljs-comment">// 先声明变量，供下面的代码使用，局部变量，可重新赋值</span><br>b1 = <span class="hljs-number">1</span>  <span class="hljs-comment">// 变量赋值</span><br><span class="hljs-keyword">let</span> b2 = <span class="hljs-number">1</span> <span class="hljs-comment">// 声明的同时赋值</span><br><br><span class="hljs-keyword">const</span> c1 = <span class="hljs-number">1</span>; <span class="hljs-comment">// 声明局部变量，但是const声明的变量，不可再次赋值</span><br>c1 = <span class="hljs-number">2</span>; <span class="hljs-comment">// 报错，const声明的变量不能再次赋值</span><br></code></pre></td></tr></table></figure>

<p>推荐使用新语法let、const，var会涉及到<strong>变量提升</strong>问题</p>
<p>变量提升问题，会涉及到<strong>预编译</strong>。</p>
<h3 id="声明规范"><a href="#声明规范" class="headerlink" title="声明规范"></a>声明规范</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-number">1.</span> 变量名不能是js中的保留字和关键字。<br>     关键字：编程语言中，用来进行语法相关的关键词<br><span class="hljs-number">2.</span> 变量名区分大小写，对大小写敏感。<br>     声明的变量在使用时，针对大小写字母是区分的。<br>     a 和 A 是不同的。<br><span class="hljs-number">3.</span> 变量名只能由字母，数字和美元符$以及下划线_组成，不能以数字开头。<br>     <span class="hljs-keyword">var</span> a-b = <span class="hljs-number">100</span>;   <span class="hljs-comment">// 报错，a-b不是合法变量名</span><br></code></pre></td></tr></table></figure>

<blockquote>
<p>关键字：<a target="_blank" rel="noopener" href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Lexical_grammar#%E5%85%B3%E9%94%AE%E5%AD%97">https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Lexical_grammar#关键字</a></p>
</blockquote>
<h1 id="数据类型"><a href="#数据类型" class="headerlink" title="数据类型"></a>数据类型</h1><p>javascript中变量的值有不同的作用或者功能。按不同的功能，值也可以区分不同的类型。</p>
<ul>
<li>Number，整数、浮点数</li>
<li>String，字符串，单引号、双引号都可以声明。还有一种叫<strong>模板字符串</strong>，使用的是反引号``</li>
<li>Boolean，布尔属性，true和false。和python不同，都是小写。</li>
<li>undefined，代表只是声明，但是没有定义值。</li>
<li>null，表示为空，相当于python的None</li>
<li>Array，数组</li>
<li>Object，字典</li>
</ul>
<p>其中可以将数据类型分为两大类：</p>
<ul>
<li>原始值<ul>
<li>Number</li>
<li>String</li>
<li>Boolean</li>
<li>undefined</li>
<li>null</li>
</ul>
</li>
<li>引用值<ul>
<li>Array</li>
<li>Object</li>
</ul>
</li>
</ul>
<p>javascript中提供了一个关键字<strong>typeof</strong>，可以让我们查看变量值的类型</p>
<blockquote>
<p>typeof 这是一个关键字，但是用法类似函数，有返回值，返回值就是数据的类型。但数组、字典的返回值都是’object’</p>
</blockquote>
<h2 id="Number"><a href="#Number" class="headerlink" title="Number"></a>Number</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> num1 = <span class="hljs-number">100</span>;<br><span class="hljs-keyword">const</span> num2 = <span class="hljs-number">1.33</span>;<br><span class="hljs-keyword">const</span> num3 = <span class="hljs-number">0</span>;<br><span class="hljs-keyword">const</span> num4 = -<span class="hljs-number">1.33</span>;<br><span class="hljs-keyword">const</span> num5 = <span class="hljs-number">1.3e10</span>;<br><span class="hljs-keyword">const</span> num6 = <span class="hljs-number">133_200_100</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num1 ); <span class="hljs-comment">// number</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num2 ); <span class="hljs-comment">// number</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num3 ); <span class="hljs-comment">// number</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num4 ); <span class="hljs-comment">// number</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num5 ); <span class="hljs-comment">// number</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( <span class="hljs-keyword">typeof</span> num6 ); <span class="hljs-comment">// number</span><br>    <br><span class="hljs-comment">// Number.MAX_VALUE表示number的最大值,如果使用的数据超过了Number.MAX_VALUE的值，则显示Infinity（正无穷大），-Infinity（负无穷大）</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-title class_">Number</span>.<span class="hljs-property">MAX_VALUE</span>)<br><br><span class="hljs-comment">// 数值类型支持算数运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 + <span class="hljs-number">100</span>); <span class="hljs-comment">// 加法运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 - <span class="hljs-number">100</span>); <span class="hljs-comment">// 减法运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 * <span class="hljs-number">100</span>); <span class="hljs-comment">// 乘法运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 / <span class="hljs-number">100</span>); <span class="hljs-comment">// 除法运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 % <span class="hljs-number">3</span>);   <span class="hljs-comment">// 取模，求余运算</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(num1 ** <span class="hljs-number">3</span>);  <span class="hljs-comment">// 幂运算</span><br></code></pre></td></tr></table></figure>

<h2 id="String类型"><a href="#String类型" class="headerlink" title="String类型"></a>String类型</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 单引号声明字符串</span><br><span class="hljs-keyword">const</span> str1 = <span class="hljs-string">&#x27;hello world&#x27;</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-keyword">typeof</span> str1); <span class="hljs-comment">// string</span><br><br><span class="hljs-comment">// 双引号单行字符串</span><br><span class="hljs-keyword">const</span> str2 = <span class="hljs-string">&quot;hello world&quot;</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-keyword">typeof</span> str2); <span class="hljs-comment">// string</span><br><br><span class="hljs-comment">// 多行文本字符串（模板字符串）</span><br><span class="hljs-keyword">const</span> str3 = <span class="hljs-string">`hello world`</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-keyword">typeof</span> str3); <span class="hljs-comment">// string</span><br><br><span class="hljs-comment">// 模板字符串类型于占位填充，比如python的f-string</span><br><span class="hljs-keyword">const</span> str4 = <span class="hljs-string">&#x27;world&#x27;</span><br><span class="hljs-keyword">const</span> str5 = <span class="hljs-string">`hello <span class="hljs-subst">$&#123;str4&#125;</span>`</span>; <span class="hljs-comment">//hello world  写在多行文本字符串中的 $&#123;变量名&#125;会被js进行识别并转换成变量的值</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(str5);<br></code></pre></td></tr></table></figure>

<h2 id="Boolean类型"><a href="#Boolean类型" class="headerlink" title="Boolean类型"></a>Boolean类型</h2><p>在js中，Boolean本质上存储的是数字，尤其是在比较的时候，感受的会更为强烈。</p>
<ul>
<li>true, 1</li>
<li>false, 0</li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> ret1 = <span class="hljs-literal">true</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( ret1, <span class="hljs-keyword">typeof</span> ret1);  <span class="hljs-comment">// true &quot;boolean&quot;</span><br><br><span class="hljs-keyword">const</span> ret2 = <span class="hljs-literal">false</span>;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( ret2, <span class="hljs-keyword">typeof</span> ret2);  <span class="hljs-comment">// false, &quot;boolean&quot;</span><br></code></pre></td></tr></table></figure>

<h2 id="Array"><a href="#Array" class="headerlink" title="Array"></a>Array</h2><p>数组代表的是一组数据，这组数据可以有0或多个。数组中的数据也叫成员，<br>类似python里面的列表，数组里面有多个成员。每个成员的值可以是任意类型。</p>
<h3 id="声明方式-直接声明"><a href="#声明方式-直接声明" class="headerlink" title="声明方式-直接声明"></a>声明方式-直接声明</h3><p>一般来说，我们创建数组，都是采用这种方式。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr0 = []<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr0, <span class="hljs-keyword">typeof</span> arr0); <span class="hljs-comment">// [] &quot;object&quot;</span><br><br><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-string">&quot;苹果&quot;</span>,<span class="hljs-string">&quot;香蕉&quot;</span>,<span class="hljs-string">&quot;梨子&quot;</span>,<span class="hljs-string">&quot;水牛&quot;</span>]<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( arr1, <span class="hljs-keyword">typeof</span> arr1 );  <span class="hljs-comment">// [&quot;苹果&quot;, &quot;香蕉&quot;, &quot;梨子&quot;, &quot;水牛&quot;] &quot;object&quot;</span><br></code></pre></td></tr></table></figure>

<h3 id="声明方式-函数声明"><a href="#声明方式-函数声明" class="headerlink" title="声明方式-函数声明"></a>声明方式-函数声明</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr2 = <span class="hljs-title class_">Array</span>(); <span class="hljs-comment">// Array本身就是一个用于创建对象的函数，虽然叫类，但实际上内部就是函数，也可以不使用new关键字</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr2, <span class="hljs-keyword">typeof</span> arr2); <span class="hljs-comment">// [] &quot;object&quot;</span><br><br><span class="hljs-comment">// 有成员的数组</span><br><span class="hljs-keyword">const</span> arr3 = <span class="hljs-title class_">Array</span>(<span class="hljs-string">&quot;苹果&quot;</span>,<span class="hljs-string">&quot;香蕉&quot;</span>,<span class="hljs-string">&quot;梨子&quot;</span>,<span class="hljs-string">&quot;水牛&quot;</span>); <span class="hljs-comment">// 函数中的参数中传递数组的成员</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>( arr3, <span class="hljs-keyword">typeof</span> arr3 ); <span class="hljs-comment">// [&quot;苹果&quot;, &quot;香蕉&quot;, &quot;梨子&quot;, &quot;水牛&quot;] &quot;object&quot;</span><br></code></pre></td></tr></table></figure>

<h3 id="为什么数组也是一个对象"><a href="#为什么数组也是一个对象" class="headerlink" title="为什么数组也是一个对象"></a>为什么数组也是一个对象</h3><p>数组我们看到的下标index，其实在数组内部，是一个key，和字典一样。</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr = []<br><br>arr[<span class="hljs-number">0</span>] = <span class="hljs-string">&#x27;test&#x27;</span><br>arr[<span class="hljs-number">1</span>] = <span class="hljs-string">&#x27;test2&#x27;</span><br>arr[<span class="hljs-number">3</span>] = <span class="hljs-string">&#x27;test3&#x27;</span><br>arr[-<span class="hljs-number">1</span>] = <span class="hljs-string">&#x27;test&#x27;</span><br>arr[<span class="hljs-string">&#x27;test&#x27;</span>] = <span class="hljs-string">&#x27;test&#x27;</span><br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr)<br><span class="hljs-comment">// 结果为：[&#x27;test1&#x27;, &#x27;test2&#x27;, empty, &#x27;test3&#x27;, -1: &#x27;test&#x27;, test: &#x27;test&#x27;]</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr.<span class="hljs-title function_">at</span>(-<span class="hljs-number">1</span>)) <span class="hljs-comment">// test3</span><br></code></pre></td></tr></table></figure>

<p>在数组中，只有正数索引，没有负数索引。</p>
<blockquote>
<p>负数索引在 ECMA 2022 标准，也就是ES13标准中得到支持。<br>arr.at(-1) 获取最后一位</p>
</blockquote>
<h3 id="嵌套"><a href="#嵌套" class="headerlink" title="嵌套"></a>嵌套</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> arr = [<br>    [<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>],<br>    [<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>]<br>]<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr)<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(arr[<span class="hljs-number">0</span>]) <span class="hljs-comment">// [1,2,3]</span><br></code></pre></td></tr></table></figure>

<h2 id="Object"><a href="#Object" class="headerlink" title="Object"></a>Object</h2><p>对象。关于对象，这里只是进行简单的介绍，后续会有专门的章节来介绍。</p>
<p>在js中，字典就是一个对象，以<code>key-value</code>的形式进行存储数据。<br>与python不同，js的字典可以直接在编写的时候，为成员定义为一个函数，而不是通过赋值的方式来定义。</p>
<p>可以看下面的例子：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs python"><span class="hljs-keyword">def</span> <span class="hljs-title function_">test</span>():<br>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;test&quot;</span>)<br><br>func_dict = &#123;<br>    <span class="hljs-string">&#x27;func&#x27;</span>: test<br>&#125;<br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript">func_dict = &#123;<br>    <span class="hljs-attr">func</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)&#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;test&quot;</span>)<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="声明方式-直接声明-1"><a href="#声明方式-直接声明-1" class="headerlink" title="声明方式-直接声明"></a>声明方式-直接声明</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> obj0 = &#123;&#125;<br><br><span class="hljs-keyword">const</span> obj1 = &#123;<br>    <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span>,<br>    <span class="hljs-attr">age</span>: <span class="hljs-number">100</span>,<br>    <span class="hljs-attr">work</span>: <span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)&#123;<br>        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;我能工作赚钱&quot;</span>)<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="嵌套-1"><a href="#嵌套-1" class="headerlink" title="嵌套"></a>嵌套</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> obj = &#123;<br>    <span class="hljs-attr">obj_child</span>: &#123;<br>        <span class="hljs-attr">name</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span><br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h3><p>可以发现，上面我们进行key的声明时，没有使用字符串的形式，而是直接声明。</p>
<p>这个是js本身就支持这么做，但我们进行这种命名时，需要注意以下两点：</p>
<ul>
<li>避免与其他变量重名</li>
<li>和变量声明时一样，有些字符不允许使用，比如 <code>-</code></li>
</ul>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 避免与其他变量重名</span><br><span class="hljs-comment">// 为什么是避免？因为你重名了也不影响，但是会影响阅读。</span><br><span class="hljs-keyword">const</span> key = <span class="hljs-string">&#x27;test&#x27;</span><br><br><span class="hljs-keyword">const</span> d = &#123;<br>    <span class="hljs-attr">key</span>: <span class="hljs-string">&#x27;key&#x27;</span>,<br>&#125;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(d) <span class="hljs-comment">// &#123;key: &#x27;key&#x27;&#125;</span><br><span class="hljs-comment">// 可以发现，并没有影响到字典key的声明</span><br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 一些特殊字符不能拿来直接声明key，参考变量的声明规则</span><br><span class="hljs-comment">// 这个时候就会报错</span><br><span class="hljs-keyword">const</span> d = &#123;<br>    m-<span class="hljs-attr">z</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span><br>&#125;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(d)<br></code></pre></td></tr></table></figure>

<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 有特殊字符的时候，就使用字符串的方式来声明key</span><br><span class="hljs-keyword">const</span> d = &#123;<br>    <span class="hljs-string">&#x27;m-z&#x27;</span>: <span class="hljs-string">&#x27;muzhou&#x27;</span><br>&#125;<br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(d)<br></code></pre></td></tr></table></figure>

<h2 id="undefined"><a href="#undefined" class="headerlink" title="undefined"></a>undefined</h2><p>定义了但是没有具体的值</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> a<br><span class="hljs-keyword">var</span> b = <span class="hljs-literal">undefined</span>;<br><span class="hljs-keyword">var</span> c = &#123;&#125;<br><span class="hljs-keyword">var</span> d = []<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(d.<span class="hljs-property">a</span>) <span class="hljs-comment">// 一个对象中没有的属性，也是undefined</span><br></code></pre></td></tr></table></figure>

<h2 id="null"><a href="#null" class="headerlink" title="null"></a>null</h2><p>相当于python中的None</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">const</span> a = <span class="hljs-literal">null</span><br></code></pre></td></tr></table></figure>

<h2 id="原始值和引用值的区别"><a href="#原始值和引用值的区别" class="headerlink" title="原始值和引用值的区别"></a>原始值和引用值的区别</h2><h3 id="原始值不可变"><a href="#原始值不可变" class="headerlink" title="原始值不可变"></a>原始值不可变</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> a = <span class="hljs-number">10</span><br><span class="hljs-keyword">var</span> b = a<br>a = <span class="hljs-number">20</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(a) <span class="hljs-comment">// 20</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(b) <span class="hljs-comment">// 10</span><br></code></pre></td></tr></table></figure>

<h3 id="引用值可变"><a href="#引用值可变" class="headerlink" title="引用值可变"></a>引用值可变</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> a = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]<br><span class="hljs-keyword">var</span> b = a<br>a[<span class="hljs-number">0</span>] = <span class="hljs-number">2</span><br>a.<span class="hljs-title function_">push</span>(<span class="hljs-number">3</span>)<br><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(a)  <span class="hljs-comment">// [2, 2, 3]</span><br><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(b)  <span class="hljs-comment">// [2, 2, 3]</span><br></code></pre></td></tr></table></figure>

<h3 id="为什么？"><a href="#为什么？" class="headerlink" title="为什么？"></a>为什么？</h3><p>这个涉及到两个概念，一个是<strong>栈 stack</strong>，一个是<strong>堆 heap</strong></p>
<p>每个变量赋值时，都会在 栈 中申请一个内存地址，来存放变量对应的值。</p>
<p>这个时候会分为两种情况：</p>
<ul>
<li>原始值，内存地址中会直接存放原始值的值，比如：10</li>
<li>引用值，引用值赋值时，会从 堆 中，申请 堆地址，将这个 堆地址 存入到变量的 栈地址 中，是<strong>引用关系</strong></li>
</ul>
<h4 id="原始值"><a href="#原始值" class="headerlink" title="原始值"></a>原始值</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 原始值赋值</span><br><span class="hljs-keyword">var</span> a = <span class="hljs-number">10</span> <span class="hljs-comment">// 内存地址为1001，值为10</span><br><span class="hljs-keyword">var</span> b = a <span class="hljs-comment">// 内存地址为1002，值会从a进行复制后存储，值为10</span><br>a = <span class="hljs-number">20</span> <span class="hljs-comment">// 内存地址为1003，值为20，原内存地址舍弃</span><br></code></pre></td></tr></table></figure>

<p>所以原始值的赋值，不会将值改变，只是重新开辟了内存空间。</p>
<p>所以a变了，b不会变。</p>
<h4 id="引用值可变-1"><a href="#引用值可变-1" class="headerlink" title="引用值可变"></a>引用值可变</h4><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs javascript"><span class="hljs-comment">// 引用值赋值</span><br><span class="hljs-keyword">var</span> a = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]  <span class="hljs-comment">// 内存地址1001，值为 堆地址heap1001</span><br><span class="hljs-keyword">var</span> b = a  <span class="hljs-comment">// 内存地址1002，值会从a中复制进行存储，值为 堆地址heap1001</span><br><br>a[<span class="hljs-number">0</span>] = <span class="hljs-number">2</span>  <span class="hljs-comment">// 直接修改 堆地址heap1001 的值，这个时候，同样是引用关系的b，打印出来的值也会随着改变</span><br><br>a = <span class="hljs-number">1</span>  <span class="hljs-comment">// 内存地址1003，值为2。重新赋值后，内存地址改变，不影响b本身的值</span><br></code></pre></td></tr></table></figure>

<p>所以引用值的赋值，会将值进行改变，因为是引用关系。</p>
<p>所以a中的元素变了，b也会变。</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/my-blog/categories/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/" class="category-chain-item">测试开发</a>
  
  
    <span>></span>
    
  <a href="/my-blog/categories/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/javascript/" class="category-chain-item">javascript</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/my-blog/tags/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91/">#测试开发</a>
      
        <a href="/my-blog/tags/%E6%B5%8B%E8%AF%95%E5%B9%B3%E5%8F%B0/">#测试平台</a>
      
        <a href="/my-blog/tags/javascript/">#javascript</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>javascript简介</div>
      <div>https://walker_kwu.gitee.io/my-blog/2022/09/20/notes/js/jsIntroduction/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>木舟</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年9月20日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2023年5月23日</div>
        </div>
      
      <div class="license-meta-item">
        <div>许可协议</div>
        <div>
          
            
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="BY - 署名">
                <i class="iconfont icon-by"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="NC - 非商业性使用">
                <i class="iconfont icon-nc"></i>
              </span>
              </a>
            
              <a target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
              <span class="hint--top hint--rounded" aria-label="SA - 相同方式共享">
                <i class="iconfont icon-sa"></i>
              </span>
              </a>
            
          
        </div>
      </div>
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/my-blog/2022/09/21/notes/js/operator/" title="运算符">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">运算符</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/my-blog/2022/09/18/autoTest/selenium/" title="selenium--最为流行的WebUI自动化工具库">
                        <span class="hidden-mobile">selenium--最为流行的WebUI自动化工具库</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <span>By 木舟</span> <i class="iconfont icon-love"></i> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/my-blog/js/events.js" ></script>
<script  src="/my-blog/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/my-blog/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      headingSelector : CONFIG.toc.headingSelector || 'h1,h2,h3,h4,h5,h6',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      collapseDepth   : CONFIG.toc.collapseDepth || 0,
      scrollSmooth    : true,
      headingsOffset  : -boardTop
    });
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.10/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/my-blog/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/my-blog/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
